"use strict";
cc._RF.push(module, 'abcd7QNE2pJSLktRijXLoHh', 'HallMatchView');
// scripts/HallMatchView.js

"use strict";

var t = require;
var e = module;
var o = exports;

var _i,
    n = void 0 && (void 0).__extends || (_i = function i(t, e) {
  return (_i = Object.setPrototypeOf || {
    __proto__: []
  } instanceof Array && function (t, e) {
    t.__proto__ = e;
  } || function (t, e) {
    for (var o in e) {
      Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
    }
  })(t, e);
}, function (t, e) {
  function o() {
    this.constructor = t;
  }

  _i(t, e), t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o());
}),
    a = void 0 && (void 0).__decorate || function (t, e, o, i) {
  var n,
      a = arguments.length,
      r = a < 3 ? e : null === i ? i = Object.getOwnPropertyDescriptor(e, o) : i;
  if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, i);else for (var s = t.length - 1; s >= 0; s--) {
    (n = t[s]) && (r = (a < 3 ? n(r) : a > 3 ? n(e, o, r) : n(e, o)) || r);
  }
  return a > 3 && r && Object.defineProperty(e, o, r), r;
};

Object.defineProperty(o, "__esModule", {
  value: !0
});

var r = t("GlobalUserData"),
    s = t("Hint"),
    l = t("Common"),
    c = t("Util"),
    d = t("ChampionManager"),
    h = t("HallCarTotalView"),
    p = t("HallConstant"),
    u = t("HallScene"),
    f = t("MatchCarView"),
    m = cc._decorator,
    _ = m.ccclass,
    y = m.property,
    g = function (t) {
  function e() {
    var e = null !== t && t.apply(this, arguments) || this;
    return e.node_cars = [], e.node_enemy_cars = [], e.btn_share = null, e.btn_starGame = null, e.btn_back = null, e.spr_head = null, e.firstBannerTouch = !0, e;
  }

  return n(e, t), e.prototype.onEnable = function () {
    for (var t = 0; t < this.node_cars.length; t++) {
      this.node_cars[t].getComponent(f["default"]).init(t);
    }

    d["default"].Ins.setGradeWithFrame(this.spr_head);
  }, e.prototype.start = function () {
    c.Util.is_wx() || (this.btn_share.node.active = !1), c.Util.hideSingleCustomAd();

    for (var t = 0; t < this.node_enemy_cars.length; t++) {
      this.node_enemy_cars[t].getComponent(f["default"]).init(t, !0);
    }
  }, e.prototype.onBtnAssembly = function (t, e) {
    r["default"].nGuideStep < p.Guide_Step.trySuperCar || !this.btn_starGame.interactable || (-1 == r["default"].swapCarIndex ? (this.node.active = !1, r["default"].isMatchToAssembly = !0, cc.find("Canvas").getChildByName("car").getComponent(h["default"]).onBtnAssembly(t, e)) : s["default"].show("已装配试玩车辆，不能改装，请开始游戏。"));
  }, e.prototype.onBtnShare = function () {
    cc.find("Canvas").getComponent(u["default"]).onBtnShare();
  }, e.prototype.onBtnGameStart = function (t, e) {
    if (this.firstBannerTouch) return this.setBtnWithStatus(!1), void c.Util.showMistakeTouchBanner(this.getAdCallBack(this.gameStart.bind(this, t, e)));
    this.gameStart(t, e);
  }, e.prototype.gameStart = function (t, e) {
    for (var o = 0; o < this.node_cars.length; o++) {
      this.node_cars[o].getChildByName("assembly").active = !1;
    }

    this.setBtnWithStatus(!1), l["default"].getIns().logEvent(l.LogEventType.MatchBtn, r["default"]._strOldUser + "" + r["default"].nTotalGame, 2), cc.find("Canvas").getComponent(u["default"]).onBtnGameStart(t, e);
  }, e.prototype.setBtnWithStatus = function (t) {
    this.btn_share.interactable = t, this.btn_starGame.interactable = t, this.btn_back.interactable = t;
  }, e.prototype.getAdCallBack = function (t) {
    var e = this;
    return {
      caller: this,
      success: function success() {
        e.scheduleOnce(function () {
          e.setBtnWithStatus(!0), c.Util.hideMistakeTouchBanner();
        }, 2), e.firstBannerTouch = !1;
      },
      failed: function failed() {
        t && t();
      },
      error: function error() {
        t && t();
      }
    };
  }, e.prototype.onBtnBackHall = function () {
    this.node.active = !1, r["default"].isMatchToAssembly = !1, cc.find("Canvas").getComponent(u["default"]).playMusic(), cc.find("Canvas").getComponent(u["default"]).comebackshow(), c.Util.is_VIVO() && !r["default"].bAuditMode && c.Util.showNativeGridAd();
  }, a([y([cc.Node])], e.prototype, "node_cars", void 0), a([y([cc.Node])], e.prototype, "node_enemy_cars", void 0), a([y(cc.Button)], e.prototype, "btn_share", void 0), a([y(cc.Button)], e.prototype, "btn_starGame", void 0), a([y(cc.Button)], e.prototype, "btn_back", void 0), a([y(cc.Sprite)], e.prototype, "spr_head", void 0), a([_], e);
}(cc.Component);

o["default"] = g;

cc._RF.pop();